package edu.gatech.volt2.drdoommgt.gui;

import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import edu.gatech.volt2.drdoommgt.domain.Name;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


@SuppressWarnings("serial")
public class DoctorWindow extends JFrame implements IDoctorView{

	private JPanel contentPane;
	private JButton createPatientButton;
	private JButton deletePatientButton;
	private JButton editPatientButton;
	private JButton viewPatientButton;
	private JButton searchPatientButton;
	private JButton createTreatmentRecordButton;
	private JButton viewAppointmentButton;
	private JButton addDocOrderButton;
	private JButton viewReportButton;
	private JButton exitButton;
	private JLabel loginLabel;
	
	/**
	 * @return the createPatientButton
	 */
	public JButton getCreatePatientButton() {
		return createPatientButton;
	}

	/**
	 * @return the delete patient button
	 */
	public JButton getDeletePatientButton() {
		return deletePatientButton;
	}
	
	/**
	 * @return the edit patient button
	 */
	public JButton getEditPatientButton() {
		return editPatientButton;
	}
	
	/**
	 * @return the view patient button
	 */
	public JButton getViewPatientButton() {
		return viewPatientButton;
	}

	/**
	 * @return the search patients button
	 */
	public JButton getSearchPatientButton() {
		return searchPatientButton;
	}
	
	/**
	 * @return the create treatment record button
	 */
	public JButton getCreateTreatmentRecordButton() {
		return createTreatmentRecordButton;
	}
	
	/**
	 * @return the view appointment button
	 */
	public JButton getViewAppointmentButton() {
		return viewAppointmentButton;
	}

	/**
	 * @return the add doc order button
	 */
	public JButton getAddDocOrderButton() {
		return addDocOrderButton;
	}
	
	/**
	 * @return the view report button
	 */
	public JButton getViewReportButton() {
		return viewReportButton;
	}
	
	/**
	 * @return the exit button
	 */
	public JButton getExitButton() {
		return exitButton;
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DoctorWindow frame = new DoctorWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public DoctorWindow() {
		setResizable(false);
		setTitle("Dr. Doom Management");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 341);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(6, 31, 438, 282);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel optionLabel = new JLabel("What would you like to do?");
		optionLabel.setHorizontalAlignment(SwingConstants.CENTER);
		optionLabel.setBounds(120, 11, 177, 29);
		panel.add(optionLabel);
		
		createPatientButton = new JButton("Create a Patient");
		createPatientButton.setBounds(10, 51, 180, 30);
		panel.add(createPatientButton);
		
		deletePatientButton = new JButton("Delete a Patient");
		deletePatientButton.setBounds(10, 92, 180, 30);
		panel.add(deletePatientButton);
		
		editPatientButton = new JButton("Edit a Patient");
		editPatientButton.setBounds(10, 133, 180, 30);
		panel.add(editPatientButton);
		
		viewPatientButton = new JButton("View Patients");
		viewPatientButton.setBounds(10, 174, 180, 30);
		panel.add(viewPatientButton);
		
		searchPatientButton = new JButton("Search Patient by Name");
		searchPatientButton.setBounds(10, 215, 180, 30);
		panel.add(searchPatientButton);
		
		createTreatmentRecordButton = new JButton("Create a Treatment Record");
		createTreatmentRecordButton.setBounds(226, 52, 194, 30);
		panel.add(createTreatmentRecordButton);
		
		viewAppointmentButton = new JButton("View Daily Appointments");
		viewAppointmentButton.setBounds(226, 92, 194, 30);
		panel.add(viewAppointmentButton);
		
		addDocOrderButton = new JButton("Add Doctor's Orders");
		addDocOrderButton.setBounds(226, 133, 194, 30);
		panel.add(addDocOrderButton);
		
		viewReportButton = new JButton("View Reports and Statistics");
		viewReportButton.setBounds(226, 174, 194, 30);
		panel.add(viewReportButton);
		
		exitButton = new JButton("Logout");
		exitButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		exitButton.setBounds(362, 253, 70, 23);
		panel.add(exitButton);
		
		loginLabel = new JLabel("Welcome ");
		loginLabel.setHorizontalAlignment(SwingConstants.TRAILING);
		loginLabel.setBounds(6, 6, 438, 16);
		contentPane.add(loginLabel);
	}

	@Override
	public void showSelf() {
		this.setVisible(true);
		
	}

	@Override
	public void addListener(ActionListener al) {
		createPatientButton.addActionListener(al);
		deletePatientButton.addActionListener(al);
		editPatientButton.addActionListener(al);
		viewPatientButton.addActionListener(al);
		searchPatientButton.addActionListener(al);
		createTreatmentRecordButton.addActionListener(al);
		viewAppointmentButton.addActionListener(al);
		addDocOrderButton.addActionListener(al);
		viewReportButton.addActionListener(al);
		exitButton.addActionListener(al);
		
		
	}

	@Override
	public void hideSelf() {
		this.setVisible(false);
		
	}

	@Override
	public void setLoginName(Name name) {
		this.loginLabel.setText("Welcome: "+name.toString());
	}
}
